home *** CD-ROM | disk | FTP | other *** search
- /********************************************************************/
- /* SOURCE CODE FILE */
- /********************************************************************/
- /*
- * >>> File name: APPL DoCommand.c
- *
- * >>> Purpose: Application specific menu handlers
- * >>> Project: PoopDraw Version 1
- * >>> Date: May 23, 1989
- * >>> By: Adam Treister
- *
- */
- /********************************************************************/
- /* For Your Information 1802 Hillside Rd. SB CA 93101 */
- /********************************************************************/
-
- #include "PoopDrawInc"
-
- void DoMenuCommand (long MenuSelectResult);
- void ApplicationInit (void);
- void ApplicationShutDown (void);
-
- private DoApple(int TheItem);
- private DoFile(int TheItem);
- private DoEdit(int TheItem);
- private DoObject(int TheItem);
-
- private void About(void);
- private void Help(void);
- private void File_New(void);
- private void File_Open(void);
- private void File_Close(void);
- private Boolean File_Save(void);
- private Boolean File_SaveAs(void);
- private void DoAModal(int id);
-
- /*------------------------------------------------------------------*/
-
- void ApplicationInit()
- {
- File_New();
- }
-
- /*------------------------------------------------------------------*/
-
- void ApplicationShutDown()
- {
- }
- /*------------------------------------------------------------------*/
-
- void DoMenuCommand(MenuSelectResult)
- long MenuSelectResult;
- {
- register int TheMenu,TheItem;
-
- TheMenu = HiWord(MenuSelectResult);
- TheItem = LoWord(MenuSelectResult);
-
- switch (TheMenu)
- {
-
- case 1000: DoApple(TheItem); break;
- case 1001: DoFile(TheItem); break;
- case 1002: DoEdit(TheItem); break;
- case 1003: DoObject(TheItem); break;
-
- }
- HiliteMenu(0);
- }
- /*------------------------------------------------------------------*/
-
- DoApple(TheItem)
- int TheItem;
- {
- Str255 daName;
- GrafPtr savePort;
- extern MenuHandle Menus[];
-
- if (TheItem == 1) DoAModal(AboutID);
- else if (TheItem == 2) DoAModal(HelpID);
- else
- {
- GetItem(Menus[0], TheItem, daName);
-
- GetPort(&savePort);
- (void) OpenDeskAcc(daName);
- SetPort(savePort);
- }
- }
-
- /*------------------------------------------------------------------*/
-
- DoFile(TheItem)
- int TheItem;
- { extern Boolean MillerTime;
-
- switch (TheItem)
- {
- case 1: File_New(); break;
- case 2: File_Open(); break;
- case 3: File_Close(); break;
- case 4: File_Save(); break;
- case 5: File_SaveAs(); break;
-
- case 7: MillerTime = TRUE; break;
-
- default: Oops("\pUnknown item in File Menu", 0, TRUE);
- }
- }
-
- /*------------------------------------------------------------------*/
-
- DoEdit(TheItem)
- int TheItem;
- {
- /* sorry,not implemented in this version */
- /* Notes:
- Undo could be implemented by saving a copy of the object and select lists.
- Objects could be written to the clipboard in a manner similar to
- writing them to a file (ie use PACK and UNPACK)
- */
- }
-
- /* ------------------------------------------------------------ */
- /* */
- /* DoObject */
- /* */
- /* */
- /* ------------------------------------------------------------ */
-
- DoObject(TheItem)
- int TheItem;
- {
- WindowPtr wP = MyFrontWindow();
- switch (TheItem)
- {
-
- case 1: WDispatch(wP,BRINGTOFRONT,NULL); break;
- case 2: WDispatch(wP,SENDTOBACK,NULL); break;
-
- case 4: WDispatch(wP,GROUP,NULL); break;
- case 5: WDispatch(wP,UNGROUP,NULL); break;
-
- default: break;
- }
- }
- /*------------------------------------------------------------------*/
-
- void DoAModal(id)
- int id;
- {
- DialogPtr dlog;
- int item;
- Rect r;
- int lft,top;
-
- dlog = GetNewDialog(id,NULL,-1L);
- r = screenBits.bounds;
- lft = ( Width(r) - Width(dlog->portRect) ) / 2;
- top = ( Height(r) - Height(dlog->portRect) ) / 2;
-
- MoveWindow(dlog,lft,top,true);
- ShowWindow(dlog);
- SetPort(dlog);
- do ModalDialog(NULL,&item);
- while (item != 1);
- DisposDialog(dlog);
- }
- /* ============================================================ */
- /* */
- /* THE FILE MENU HANDLERS */
- /* */
- /* ============================================================ */
-
- void File_New()
- {
- WindowPtr wP;
-
- New(DRAWWIND,NULL,&wP);
- }
-
- /*------------------------------------------------------------------*/
-
- void File_Open()
- {
- WindowPtr wP;
- Handle h;
-
- if (h = ReadFileToHandle())
- {
- New(DRAWWIND,NULL,&wP);
- WDispatch(wP,LOAD,h);
- }
- }
-
- /*------------------------------------------------------------------*/
- void File_Close()
- {
- WDispatch(MyFrontWindow(),CLOSE,NULL);
- }
-
- /*------------------------------------------------------------------*/
-
- Boolean File_Save()
- {
- long DoSaveAs = NULL;
- WDispatch(MyFrontWindow(),SAVE,&DoSaveAs);
- }
-
- /*------------------------------------------------------------------*/
-
- Boolean File_SaveAs()
- {
- long DoSaveAs = 1L;
- WDispatch(MyFrontWindow(),SAVE,&DoSaveAs);
- }
- /********************************************************/
-